package com.labor_management_system.Service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.labor_management_system.Entity.Employee;
import com.labor_management_system.Entity.Team;
import com.labor_management_system.Service.EmployeeService;
import com.labor_management_system.Mapper.EmployeeMapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;


@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee>
    implements EmployeeService {
    @Override
    public List<String> getEmployeeIDByTeamID(String teamID) {
        QueryWrapper wrapper = new QueryWrapper<>();
        wrapper.eq("team_id",teamID);
        List<Employee> t = baseMapper.selectList(wrapper);
        return t.stream().map(Employee::getEmployeeId).collect(Collectors.toList());
    }

    @Override
    public String getEmployeeNameByID(String employeeID) {
        return baseMapper.selectById(employeeID).getEmployeeName();
    }

    @Override
    public List<String> getEmployeeIdByName(String employeeName) {
        QueryWrapper wrapper = new QueryWrapper<>();
        wrapper.like("employee_name",employeeName);
        List<Employee> t = baseMapper.selectList(wrapper);
        return t.stream().map(Employee::getEmployeeId).collect(Collectors.toList());
    }
    //员工
}




